# 房屋贷款问题
# 每月还款金额 = 贷款金额*月利率/[1-1/(1+月利率)^(贷款年限*12)]

# 贷款金额
Loan_amount = eval(input("Please enter the loan amount:"))
# 贷款年限
Loan_term = eval(input("Please enter the loan term:"))
# 贷款利率
Loan_rate = eval(input("Please enter the loan rate:"))
# 将年利率转化为月利率,注意是百分比
month_rate = Loan_rate / (12 * 100)
print(f"{Loan_amount=},{Loan_term=},{Loan_rate=},{month_rate=}")

# 分子部分 = 贷款金额*月利率
Molecule = Loan_amount * month_rate

# 分母部分 = 1-1/(1+月利率)^(贷款年限*12)
Denominator = 1-(1/(1 + month_rate) ** (Loan_term * 12))

# 每月还款金额
monthly_pay = Molecule / Denominator
print(f"Monthly repayment amount:{monthly_pay}")

# 总还款金额
total_pay = monthly_pay * Loan_term * 12
print(f"Total repayment amount:{total_pay}")
